package com.mku.wms_service.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @className: Response
 * @author: Maoxx
 * @date: 2024/11/22 23:57
 * @Version: 1.0
 * @description:
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Response <T> {
    private Integer code;
    private String message;
    private Long total;//总记录数
    private T data;

    public static <T> Response<T>  success() {
        return new Response<T>(200, "成功", 0L, null);
    }

    public static <T> Response<T>  success(T data) {
        return new Response<T>(200, "成功", 0L, data);
    }

    public static <T> Response<T>  success(T data, Long total) {
        return new Response<T>(200, "成功", total, data);
    }

    public static <T> Response<T>  fail(String message) {
        return new Response<T>(500, message, 0L, null);
    }

    public static <T> Response<T>  fail(Integer code, String message) {
        return new Response<T>(code, message, 0L, null);
    }
}
